home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Utilities / Font Management Utility / Deutsch / Xerox Font Management Utility.msi / Data1.cab / F3722_Fmu.chm / skinsupport / madcaputilities.js < prev   
Text File  |  2009-07-16  |  64KB  |  2,821 lines

  1. // {{MadCap}} //////////////////////////////////////////////////////////////////
  2. // Copyright: MadCap Software, Inc - www.madcapsoftware.com ////////////////////
  3. ////////////////////////////////////////////////////////////////////////////////
  4. // <version>3.0.0.0</version>
  5. ////////////////////////////////////////////////////////////////////////////////
  6.  
  7. var gLoaded                    = false;
  8. var gOnloadFuncs            = new Array();
  9. var gPreviousOnloadFunction    = window.onload;
  10. var gReady                    = false;
  11.  
  12. if ( gPreviousOnloadFunction != null )
  13. {
  14.     gOnloadFuncs.push( gPreviousOnloadFunction );
  15. }
  16.  
  17. window.onload = function()
  18. {
  19.     gReady = true;
  20.     
  21.     MCGlobals.Init();
  22.     
  23.     FMCRegisterCallback( "MCGlobals", MCEventType.OnInit, OnMCGlobalsInit, null );
  24. };
  25.  
  26. function OnMCGlobalsInit( args )
  27. {
  28.     gLoaded = true;
  29.     
  30.     for ( var i = 0; i < gOnloadFuncs.length; i++ )
  31.     {
  32.         gOnloadFuncs[i]();
  33.     }
  34. }
  35.  
  36. var MCGlobals    = new function()
  37. {
  38.     // Private member variables
  39.     
  40.     var mSelf    = this;
  41.     
  42.     // Public properties
  43.  
  44.     this.SubsystemFile        = "Fmu.xml";
  45.     this.SkinFolder            = "Data/Skinmain/";
  46.     this.SkinTemplateFolder    = "Skin/";
  47.     this.DefaultStartTopic    = "Fmu/Xerox_Font_Management_Utility.htm";
  48.     this.InPreviewMode      = false;
  49.     
  50.     this.Initialized        = false;
  51.     
  52.     this.RootFolder            = null;
  53.     this.RootFrame            = null;
  54.     this.ToolbarFrame        = null;
  55.     this.BodyFrame            = null;
  56.     this.NavigationFrame    = null;
  57.     this.TopicCommentsFrame    = null;
  58.     this.BodyCommentsFrame    = null;
  59.     this.PersistenceFrame    = null;
  60.     
  61.     // Private methods
  62.     
  63.     function InitRoot()
  64.     {
  65.         mSelf.RootFrame = window;
  66.         mSelf.ToolbarFrame = frames["mctoolbar"];
  67.         mSelf.BodyFrame = frames["body"];
  68.         mSelf.NavigationFrame = frames["navigation"];
  69.         mSelf.PersistenceFrame = null;
  70.         
  71.         //
  72.         
  73.         var bodyReady    = false;
  74.         
  75.         FMCRegisterCallback( "Navigation", MCEventType.OnReady, OnNavigationReady, null );
  76.         
  77.         function OnNavigationReady( args )
  78.         {
  79.             mSelf.TopicCommentsFrame = mSelf.NavigationFrame.frames["topiccomments"];
  80.             
  81.             //
  82.             
  83.             if ( bodyReady )
  84.             {
  85.                 mSelf.Initialized = true;
  86.             }
  87.         }
  88.         
  89.         FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  90.             
  91.         function OnBodyReady( args )
  92.         {
  93.             mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  94.             
  95.             //
  96.             
  97.             bodyReady = true;
  98.             
  99.             if ( mSelf.TopicCommentsFrame != null )
  100.             {
  101.                 mSelf.Initialized = true;
  102.             }
  103.         }
  104.     }
  105.     
  106.     function InitTopicCHM()
  107.     {
  108.         mSelf.RootFrame = null;
  109.         mSelf.ToolbarFrame = frames["mctoolbar"];
  110.         mSelf.BodyFrame = window;
  111.         mSelf.NavigationFrame = null;
  112.         mSelf.TopicCommentsFrame = null;
  113.         mSelf.BodyCommentsFrame = frames["topiccomments"];
  114.         mSelf.PersistenceFrame = frames["persistence"];
  115.         
  116.         //
  117.             
  118.         mSelf.Initialized = true;
  119.     }
  120.     
  121.     function InitNavigation()
  122.     {
  123.         mSelf.RootFrame = parent;
  124.         mSelf.NavigationFrame = window;
  125.         mSelf.TopicCommentsFrame = frames["topiccomments"];
  126.         mSelf.PersistenceFrame = null;
  127.         
  128.         FMCRegisterCallback( "Root", MCEventType.OnReady, OnRootReady, null );
  129.             
  130.         function OnRootReady( args )
  131.         {
  132.             mSelf.ToolbarFrame = mSelf.RootFrame.frames["mctoolbar"];
  133.             mSelf.BodyFrame = mSelf.RootFrame.frames["body"];
  134.             
  135.             FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  136.             
  137.             function OnBodyReady( args )
  138.             {
  139.                 mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  140.                 
  141.                 //
  142.                 
  143.                 mSelf.Initialized = true;
  144.             }
  145.         }
  146.     }
  147.     
  148.     function InitNavigationFramesWebHelp()
  149.     {
  150.         var bodyReady    = false;
  151.         
  152.         mSelf.RootFrame = parent.parent;
  153.         mSelf.NavigationFrame = parent;
  154.         mSelf.PersistenceFrame = null;
  155.         
  156.         FMCRegisterCallback( "Root", MCEventType.OnReady, OnRootReady, null );
  157.             
  158.         function OnRootReady( args )
  159.         {
  160.             mSelf.ToolbarFrame = mSelf.RootFrame.frames["mctoolbar"];
  161.             mSelf.BodyFrame = mSelf.RootFrame.frames["body"];
  162.             
  163.             FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  164.             
  165.             function OnBodyReady( args )
  166.             {
  167.                 mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  168.                 
  169.                 //
  170.                 
  171.                 bodyReady = true;
  172.                 
  173.                 if ( mSelf.TopicCommentsFrame != null )
  174.                 {
  175.                     mSelf.Initialized = true;
  176.                 }
  177.             }
  178.         }
  179.         
  180.         FMCRegisterCallback( "Navigation", MCEventType.OnReady, OnNavigationReady, null );
  181.             
  182.         function OnNavigationReady( args )
  183.         {
  184.             mSelf.TopicCommentsFrame = mSelf.NavigationFrame.frames["topiccomments"];
  185.             
  186.             //
  187.             
  188.             if ( bodyReady )
  189.             {
  190.                 mSelf.Initialized = true;
  191.             }
  192.         }
  193.     }
  194.     
  195.     function InitBodyCommentsFrameWebHelp()
  196.     {
  197.         mSelf.RootFrame = parent.parent;
  198.         mSelf.NavigationFrame = parent.parent.frames["navigation"];
  199.         mSelf.PersistenceFrame = null;
  200.         mSelf.ToolbarFrame = parent.parent.frames["mctoolbar"];
  201.         mSelf.BodyFrame = parent;
  202.         mSelf.BodyCommentsFrame = window;
  203.         
  204.         FMCRegisterCallback( "Navigation", MCEventType.OnReady, OnNavigationReady, null );
  205.             
  206.         function OnNavigationReady( args )
  207.         {
  208.             mSelf.TopicCommentsFrame = mSelf.NavigationFrame.frames["topiccomments"];
  209.             
  210.             //
  211.             
  212.             mSelf.Initialized = true;
  213.         }
  214.     }
  215.     
  216.     function InitBodyCommentsFrameDotNetHelp()
  217.     {
  218.         mSelf.RootFrame = null;
  219.         mSelf.ToolbarFrame = null;
  220.         mSelf.BodyFrame = parent;
  221.         mSelf.NavigationFrame = null;
  222.         mSelf.TopicCommentsFrame = null;
  223.         mSelf.BodyCommentsFrame = window;
  224.         mSelf.PersistenceFrame = null;
  225.  
  226.         //
  227.  
  228.         mSelf.Initialized = true;
  229.     }
  230.     
  231.     function InitToolbarWebHelp()
  232.     {
  233.         mSelf.RootFrame = parent;
  234.         mSelf.ToolbarFrame = window;
  235.         mSelf.PersistenceFrame = null;
  236.         
  237.         FMCRegisterCallback( "Root", MCEventType.OnReady, OnRootReady, null );
  238.             
  239.         function OnRootReady( args )
  240.         {
  241.             mSelf.BodyFrame = mSelf.RootFrame.frames["body"];
  242.             mSelf.NavigationFrame = mSelf.RootFrame.frames["navigation"];
  243.             
  244.             //
  245.             
  246.             var bodyReady    = false;
  247.             
  248.             FMCRegisterCallback( "Navigation", MCEventType.OnReady, OnNavigationReady, null );
  249.             
  250.             function OnNavigationReady( args )
  251.             {
  252.                 mSelf.TopicCommentsFrame = mSelf.NavigationFrame.frames["topiccomments"];
  253.                 
  254.                 //
  255.                 
  256.                 if ( bodyReady )
  257.                 {
  258.                     mSelf.Initialized = true;
  259.                 }
  260.             }
  261.             
  262.             FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  263.             
  264.             function OnBodyReady( args )
  265.             {
  266.                 mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  267.                 
  268.                 //
  269.                 
  270.                 bodyReady = true;
  271.                 
  272.                 if ( mSelf.TopicCommentsFrame != null )
  273.                 {
  274.                     mSelf.Initialized = true;
  275.                 }
  276.             }
  277.         }
  278.     }
  279.     
  280.     function InitToolbarCHM()
  281.     {
  282.         mSelf.RootFrame = null;
  283.         mSelf.ToolbarFrame = window;
  284.         mSelf.BodyFrame = parent;
  285.         mSelf.NavigationFrame = null;
  286.         mSelf.TopicCommentsFrame = null;
  287.         
  288.         FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  289.             
  290.         function OnBodyReady( args )
  291.         {
  292.             mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  293.             mSelf.PersistenceFrame = mSelf.BodyFrame.frames["persistence"];
  294.             
  295.             //
  296.         
  297.             mSelf.Initialized = true;
  298.         }
  299.     }
  300.     
  301.     function InitTopicWebHelp()
  302.     {
  303.         mSelf.RootFrame = parent;
  304.         mSelf.BodyFrame = window;
  305.         mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  306.         mSelf.PersistenceFrame = null;
  307.         
  308.         FMCRegisterCallback( "Root", MCEventType.OnReady, OnRootReady, null );
  309.         
  310.         function OnRootReady( args )
  311.         {
  312.             mSelf.ToolbarFrame = mSelf.RootFrame.frames["mctoolbar"];
  313.             mSelf.NavigationFrame = mSelf.RootFrame.frames["navigation"];
  314.             
  315.             FMCRegisterCallback( "Navigation", MCEventType.OnReady, OnNavigationReady, null );
  316.             
  317.             function OnNavigationReady( args )
  318.             {
  319.                 mSelf.TopicCommentsFrame = mSelf.NavigationFrame.frames["topiccomments"];
  320.                 
  321.                 //
  322.             
  323.                 mSelf.Initialized = true;
  324.             }
  325.         }
  326.     }
  327.     
  328.     function InitTopicDotNetHelp()
  329.     {
  330.         mSelf.RootFrame = null;
  331.         mSelf.ToolbarFrame = null;
  332.         mSelf.BodyFrame = window;
  333.         mSelf.NavigationFrame = null;
  334.         mSelf.TopicCommentsFrame = null;
  335.         mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  336.         mSelf.PersistenceFrame = null;
  337.  
  338.         //
  339.  
  340.         mSelf.Initialized = true;
  341.     }
  342.     
  343.     function InitNavigationFramesCHM()
  344.     {
  345.         mSelf.RootFrame = null;
  346.         mSelf.BodyFrame = parent;
  347.         mSelf.NavigationFrame = null;
  348.         mSelf.TopicCommentsFrame = null;
  349.         
  350.         FMCRegisterCallback( "Body", MCEventType.OnReady, OnBodyReady, null );
  351.             
  352.         function OnBodyReady( args )
  353.         {
  354.             mSelf.ToolbarFrame = mSelf.BodyFrame.frames["mctoolbar"];
  355.             mSelf.BodyCommentsFrame = mSelf.BodyFrame.frames["topiccomments"];
  356.             mSelf.PersistenceFrame = mSelf.BodyFrame.frames["persistence"];
  357.             
  358.             //
  359.         
  360.             mSelf.Initialized = true;
  361.         }
  362.     }
  363.     
  364.     // Public methods
  365.     
  366.     this.Init    = function()
  367.     {
  368.         if ( FMCInPreviewMode() )
  369.         {
  370.             mSelf.Initialized = true;
  371.             
  372.             return;
  373.         }
  374.         
  375.         if ( frames["mctoolbar"] != null )    // Root or topic in CHM
  376.         {
  377.             mSelf.ToolbarFrame = frames["mctoolbar"];
  378.             
  379.             if ( frames["body"] != null )    // Root
  380.             {
  381.                 InitRoot();
  382.             }
  383.             else                            // Topic in CHM
  384.             {
  385.                 InitTopicCHM();
  386.             }
  387.         }
  388.         else if ( window.name == "navigation" )    // Navigation
  389.         {
  390.             InitNavigation();
  391.         }
  392.         else if ( parent.name == "navigation" )    // Navigation frames in WebHelp
  393.         {
  394.             InitNavigationFramesWebHelp();
  395.         }
  396.         else if ( window.name == "mctoolbar" )    // Toolbar
  397.         {
  398.             mSelf.ToolbarFrame = window;
  399.             
  400.             if ( parent.frames["navigation"] != null )    // Toolbar in WebHelp
  401.             {
  402.                 InitToolbarWebHelp();
  403.             }
  404.             else                                        // Toolbar in CHM
  405.             {
  406.                 InitToolbarCHM();
  407.             }
  408.         }
  409.         else if ( FMCIsTopicPopup() )   // Topic popup
  410.         {
  411.             mSelf.Initialized = true;
  412.             
  413.             return;
  414.         }
  415.         else if ( window.name == "body" )    // Topic in WebHelp
  416.         {
  417.             if ( FMCIsWebHelp() )
  418.             {
  419.                 InitTopicWebHelp();
  420.             }
  421.             else if ( FMCIsDotNetHelp() )
  422.             {
  423.                 InitTopicDotNetHelp();
  424.             }
  425.             else if ( FMCIsHtmlHelp() )
  426.             {
  427.                 InitTopicCHM();
  428.             }
  429.         }
  430.         else if ( window.name == "topiccomments" )
  431.         {
  432.             if ( parent.name != "body" )
  433.             {
  434.                 mSelf.Initialized = true;
  435.                 
  436.                 return;
  437.             }
  438.             
  439.             if ( FMCIsHtmlHelp() )
  440.             {
  441.                 InitNavigationFramesCHM();    // Body comments frame in CHM
  442.             }
  443.             else if ( FMCIsWebHelp() )
  444.             {
  445.                 InitBodyCommentsFrameWebHelp();    // Body comments frame in WebHelp body
  446.             }
  447.             else if ( FMCIsDotNetHelp() )
  448.             {
  449.                 InitBodyCommentsFrameDotNetHelp();    // Body comments frame in DotNet Help body
  450.             }
  451.         }
  452.         else if (    window.name == "toc" ||
  453.                     window.name == "index" ||
  454.                     window.name == "search" ||
  455.                     window.name == "glossary" ||
  456.                     window.name == "favorites" ||
  457.                     window.name == "browsesequences" ||
  458.                     window.name == "recentcomments" )    // Navigation frames in CHM
  459.         {
  460.             InitNavigationFramesCHM();
  461.         }
  462.         else if ( FMCIsDotNetHelp() )
  463.         {
  464.             mSelf.Initialized = true;
  465.         }
  466.         else
  467.         {
  468.             mSelf.Initialized = true;
  469.             
  470.             return;
  471.         }
  472.         
  473.         if ( FMCIsWebHelp() )
  474.         {
  475.             var rootFolder    = mSelf.RootFrame.document.location.href.substring( 0, mSelf.RootFrame.document.location.href.lastIndexOf( "/" ) + 1 );
  476.             var subFolder    = document.location.href.substring( 0, document.location.href.lastIndexOf( "/" ) + 1 );
  477.             
  478.             if ( subFolder.StartsWith( rootFolder + "Subsystems", false ) )
  479.             {
  480.                 var href    = document.location.href;
  481.                 var subPart    = document.location.href.substring( (rootFolder + "Subsystems").length + 1 );
  482.                 
  483.                 subPart = subPart.substring( 0, subPart.indexOf( "/" ) + 1 );
  484.                 rootFolder = rootFolder + "Subsystems/" + subPart;
  485.                 
  486.                 rootFolder = rootFolder.replace( /\\/g, "/" );
  487.                 rootFolder = rootFolder.replace( /%20/g, " " );
  488.                 rootFolder = rootFolder.replace( /;/g, "%3B" );    // For Safari
  489.                 
  490.                 mSelf.RootFolder = rootFolder;
  491.             }
  492.             else if ( subFolder.StartsWith( rootFolder + "AutoMerge", false ) )
  493.             {
  494.                 var href    = document.location.href;
  495.                 var subPart    = document.location.href.substring( (rootFolder + "AutoMerge").length + 1 );
  496.                 
  497.                 subPart = subPart.substring( 0, subPart.indexOf( "/" ) + 1 );
  498.                 rootFolder = rootFolder + "AutoMerge/" + subPart;
  499.                 
  500.                 rootFolder = rootFolder.replace( /\\/g, "/" );
  501.                 rootFolder = rootFolder.replace( /%20/g, " " );
  502.                 rootFolder = rootFolder.replace( /;/g, "%3B" );    // For Safari
  503.                 
  504.                 mSelf.RootFolder = rootFolder;
  505.             }
  506.             else
  507.             {
  508.                 mSelf.RootFolder = FMCGetRootFolder( mSelf.RootFrame.document.location );
  509.             }
  510.         }
  511.         else if ( FMCIsHtmlHelp() )
  512.         {
  513.             mSelf.RootFolder = "/";
  514.         }
  515.         else if ( FMCIsDotNetHelp() )
  516.         {
  517.             var rootFolder    = FMCGetRootFolder( mSelf.BodyFrame.document.location );
  518.             
  519.             mSelf.RootFolder = rootFolder.substring( 0, rootFolder.lastIndexOf( "/", rootFolder.length - 2 ) + 1 );
  520.         }
  521.     }
  522. }
  523.  
  524. //
  525. //    Helper functions
  526. //
  527.  
  528. var gImages    = new Array();
  529.  
  530. function FMCIsWebHelp()
  531. {
  532.     return FMCGetRootFrame() != null;
  533. }
  534.  
  535. function FMCIsHtmlHelp()
  536. {
  537.     var href    = document.location.href;
  538.     
  539.     return href.indexOf( "mk:" ) == 0;
  540. }
  541.  
  542. function FMCIsDotNetHelp()
  543. {
  544.     return FMCGetRootFrame() == null && !FMCIsHtmlHelp();
  545. }
  546.  
  547. function FMCIsTopicPopup()
  548. {
  549.     return window.parent != window && window.parent.name == "body";
  550. }
  551.  
  552. var gLiveHelpEnabled    = null;
  553.  
  554. function FMCIsLiveHelpEnabled()
  555. {
  556.     if ( gLiveHelpEnabled == null )
  557.     {
  558.         var xmlDoc        = CMCXmlParser.GetXmlDoc( MCGlobals.RootFolder + MCGlobals.SubsystemFile, false, null, null );
  559.         
  560.         if ( xmlDoc == null )
  561.         {
  562.             gLiveHelpEnabled = false;
  563.         }
  564.         else
  565.         {
  566.             var projectID    = xmlDoc.documentElement.getAttribute( "LiveHelpOutputId" );
  567.             
  568.             gLiveHelpEnabled = projectID != null;
  569.         }
  570.     }
  571.     
  572.     return gLiveHelpEnabled;
  573. }
  574.  
  575. function FMCInPreviewMode()
  576. {
  577.     return MCGlobals.InPreviewMode;
  578. }
  579.  
  580. var gSkinPreviewMode    = null;
  581.  
  582. function FMCIsSkinPreviewMode()
  583. {
  584.     if ( gSkinPreviewMode == null )
  585.     {
  586.         var xmlDoc        = CMCXmlParser.GetXmlDoc( MCGlobals.RootFolder + MCGlobals.SubsystemFile, false, null, null );
  587.         
  588.         if ( xmlDoc == null )
  589.         {
  590.             gSkinPreviewMode = false;
  591.         }
  592.         else
  593.         {
  594.             gSkinPreviewMode = FMCGetAttributeBool( xmlDoc.documentElement, "SkinPreviewMode", false );
  595.         }
  596.     }
  597.     
  598.     return gSkinPreviewMode;
  599. }
  600.  
  601. function FMCIsIE55()
  602. {
  603.     return navigator.appVersion.indexOf( "MSIE 5.5" ) != -1;
  604. }
  605.  
  606. function FMCIsSafari()
  607. {
  608.     return typeof( document.clientHeight ) != "undefined";
  609. }
  610.  
  611. function FMCGetSkinFolder()
  612. {
  613.     var skinFolder    = null;
  614.     
  615.     if ( MCGlobals.RootFrame != null )
  616.     {
  617.         skinFolder = MCGlobals.RootFrame.gSkinFolder;
  618.     }
  619.     else
  620.     {
  621.         skinFolder = MCGlobals.SkinFolder;
  622.     }
  623.     
  624.     return skinFolder;
  625. }
  626.  
  627. function FMCGetHref( currLocation )
  628. {
  629.     var href    = currLocation.protocol + (!FMCIsHtmlHelp() ? "//" : "") + currLocation.host + currLocation.pathname;
  630.  
  631.     href = FMCEscapeHref( href );
  632.  
  633.     return href;
  634. }
  635.  
  636. function FMCEscapeHref( href )
  637. {
  638.     var newHref    = href.replace( /\\/g, "/" );
  639.     newHref = newHref.replace( /%20/g, " " );
  640.     newHref = newHref.replace( /;/g, "%3B" );    // For Safari
  641.  
  642.     return newHref;
  643. }
  644.  
  645. function FMCGetRootFolder( currLocation )
  646. {
  647.     var href        = FMCGetHref( currLocation );
  648.     var rootFolder    = href.substring( 0, href.lastIndexOf( "/" ) + 1 );
  649.  
  650.     return rootFolder;
  651. }
  652.  
  653. function FMCGetPathnameFolder( currLocation )
  654. {
  655.     var pathname    = currLocation.pathname;
  656.  
  657.     // This is for when viewing over a network. IE needs the path to be like this.
  658.  
  659.     if ( currLocation.protocol.StartsWith( "file" ) )
  660.     {
  661.         if ( !currLocation.host.IsNullOrEmpty() )
  662.         {
  663.             pathname = "/" + currLocation.host + currLocation.pathname;
  664.         }
  665.     }
  666.  
  667.     //
  668.  
  669.     pathname = pathname.replace( /\\/g, "/" );
  670.     //pathname = pathname.replace( /%20/g, " " );
  671.     pathname = pathname.replace( /;/g, "%3B" );    // For Safari
  672.     pathname = pathname.substring( 0, pathname.lastIndexOf( "/" ) + 1 );
  673.  
  674.     return pathname;
  675. }
  676.  
  677. function FMCGetRootFrame()
  678. {
  679.     var currWindow    = window;
  680.     
  681.     while ( currWindow )
  682.     {
  683.         if ( currWindow.gRootFolder )
  684.         {
  685.             break;
  686.         }
  687.         else if ( currWindow == top )
  688.         {
  689.             currWindow = null;
  690.             
  691.             break;
  692.         }
  693.         
  694.         currWindow = currWindow.parent;
  695.     }
  696.     
  697.     return currWindow;
  698. }
  699.  
  700. function FMCPreloadImage( imgPath )
  701. {
  702.     if ( imgPath == null )
  703.     {
  704.         return;
  705.     }
  706.     
  707.     if ( imgPath.StartsWith( "url", false ) && imgPath.EndsWith( ")", false ) )
  708.     {
  709.         imgPath = FMCStripCssUrl( imgPath );
  710.     }
  711.     
  712.     var index    = gImages.length;
  713.     
  714.     gImages[index] = new Image();
  715.     gImages[index].src = imgPath;
  716. }
  717.  
  718. function FMCTrim( str )
  719. {
  720.     return FMCLTrim( FMCRTrim( str ) );
  721. }
  722.  
  723. function FMCLTrim( str )
  724. {
  725.     for ( var i = 0; i < str.length && str.charAt( i ) == " "; i++ );
  726.     
  727.     return str.substring( i, str.length );
  728. }
  729.  
  730. function FMCRTrim( str )
  731. {
  732.     for ( var i = str.length - 1; i >= 0 && str.charAt( i ) == " "; i-- );
  733.     
  734.     return str.substring( 0, i + 1 );
  735. }
  736.  
  737. function FMCContainsClassRoot( className )
  738. {
  739.     var ret = null;
  740.     
  741.     for ( var i = 1; i < FMCContainsClassRoot.arguments.length; i++ )
  742.     {
  743.         var classRoot = arguments[i];
  744.         
  745.         if ( className && (className == classRoot || className.indexOf( classRoot + "_" ) == 0) )
  746.         {
  747.             ret = classRoot;
  748.             
  749.             break;
  750.         }
  751.     }
  752.     
  753.     return ret;
  754. }
  755.  
  756. function FMCGetChildNodeByTagName( node, tagName, index )
  757. {
  758.     var foundNode   = null;
  759.     var numFound    = -1;
  760.     
  761.     for ( var currNode = node.firstChild; currNode != null; currNode = currNode.nextSibling )
  762.     {
  763.         if ( currNode.nodeName == tagName )
  764.         {
  765.             numFound++;
  766.             
  767.             if ( numFound == index )
  768.             {
  769.                 foundNode = currNode;
  770.                 
  771.                 break;
  772.             }
  773.         }
  774.     }
  775.     
  776.     return foundNode;
  777. }
  778.  
  779. function FMCGetChildNodesByTagName( node, tagName )
  780. {
  781.     var nodes   = new Array();
  782.     
  783.     for ( var i = 0; i < node.childNodes.length; i++ )
  784.     {
  785.         if ( node.childNodes[i].nodeName == tagName )
  786.         {
  787.             nodes[nodes.length] = node.childNodes[i];
  788.         }
  789.     }
  790.     
  791.     return nodes;
  792. }
  793.  
  794. function FMCStringToBool( stringValue )
  795. {
  796.     var boolValue        = false;
  797.     var stringValLower    = stringValue.toLowerCase();
  798.  
  799.     boolValue = stringValLower == "true" || stringValLower == "1" || stringValLower == "yes";
  800.  
  801.     return boolValue;
  802. }
  803.  
  804. function FMCGetAttributeBool( node, attributeName, defaultValue )
  805. {
  806.     var boolValue    = defaultValue;
  807.     var value        = FMCGetAttribute( node, attributeName );
  808.     
  809.     if ( value )
  810.     {
  811.         boolValue = FMCStringToBool( value );
  812.     }
  813.     
  814.     return boolValue;
  815. }
  816.  
  817. function FMCGetAttributeInt( node, attributeName, defaultValue )
  818. {
  819.     var intValue    = defaultValue;
  820.     var value        = FMCGetAttribute( node, attributeName );
  821.     
  822.     if ( value != null )
  823.     {
  824.         intValue = parseInt( value );
  825.     }
  826.     
  827.     return intValue;
  828. }
  829.  
  830. function FMCGetAttribute( node, attribute )
  831. {
  832.     var value   = null;
  833.     
  834.     if ( node.getAttribute( attribute ) != null )
  835.     {
  836.         value = node.getAttribute( attribute );
  837.     }
  838.     else if ( node.getAttribute( attribute.toLowerCase() ) != null )
  839.     {
  840.         value = node.getAttribute( attribute.toLowerCase() );
  841.     }
  842.     else
  843.     {
  844.         var namespaceIndex    = attribute.indexOf( ":" );
  845.         
  846.         if ( namespaceIndex != -1 )
  847.         {
  848.             value = node.getAttribute( attribute.substring( namespaceIndex + 1, attribute.length ) );
  849.         }
  850.     }
  851.     
  852.     if ( typeof( value ) == "string" && value == "" )
  853.     {
  854.         value = null;
  855.     }
  856.     
  857.     return value;
  858. }
  859.  
  860. function FMCGetMCAttribute( node, attribute )
  861. {
  862.     var value    = null;
  863.     
  864.     if ( node.getAttribute( attribute ) != null )
  865.     {
  866.         value = node.getAttribute( attribute );
  867.     }
  868.     else if ( node.getAttribute( attribute.substring( "MadCap:".length, attribute.length ) ) )
  869.     {
  870.         value = node.getAttribute( attribute.substring( "MadCap:".length, attribute.length ) );
  871.     }
  872.     
  873.     return value;
  874. }
  875.  
  876. function FMCRemoveMCAttribute( node, attribute )
  877. {
  878.     var value    = null;
  879.     
  880.     if ( node.getAttribute( attribute ) != null )
  881.     {
  882.         value = node.removeAttribute( attribute );
  883.     }
  884.     else if ( node.getAttribute( attribute.substring( "MadCap:".length, attribute.length ) ) )
  885.     {
  886.         value = node.removeAttribute( attribute.substring( "MadCap:".length, attribute.length ) );
  887.     }
  888.     
  889.     return value;
  890. }
  891.  
  892. function FMCGetClientWidth( winNode, includeScrollbars )
  893. {
  894.     var clientWidth = null;
  895.     
  896.     if ( typeof( winNode.innerWidth ) != "undefined" )
  897.     {
  898.         clientWidth = winNode.innerWidth;
  899.         
  900.         if ( !includeScrollbars && FMCGetScrollHeight( winNode ) > winNode.innerHeight )
  901.         {
  902.             clientWidth -= 19;
  903.         }
  904.     }
  905.     else if ( FMCIsIE55() || (winNode.document.compatMode && winNode.document.compatMode == "BackCompat") )
  906.     {
  907.         clientWidth = winNode.document.body.clientWidth;
  908.     }
  909.     else if ( winNode.document.documentElement )
  910.     {
  911.         clientWidth = winNode.document.documentElement.clientWidth;
  912.     }
  913.     
  914.     return clientWidth;
  915. }
  916.  
  917. function FMCGetClientHeight( winNode, includeScrollbars )
  918. {
  919.     var clientHeight    = null;
  920.     
  921.     if ( typeof( winNode.innerHeight ) != "undefined" )
  922.     {
  923.         clientHeight = winNode.innerHeight;
  924.         
  925.         if ( !includeScrollbars && FMCGetScrollWidth( winNode ) > winNode.innerWidth )
  926.         {
  927.             clientHeight -= 19;
  928.         }
  929.     }
  930.     else if ( FMCIsIE55() || (winNode.document.compatMode && winNode.document.compatMode == "BackCompat") )
  931.     {
  932.         clientHeight = winNode.document.body.clientHeight;
  933.     }
  934.     else if ( winNode.document.documentElement )
  935.     {
  936.         clientHeight = winNode.document.documentElement.clientHeight;
  937.     }
  938.     
  939.     return clientHeight;
  940. }
  941.  
  942. function FMCGetClientCenter( winNode )
  943. {
  944.     var centerX    = FMCGetScrollLeft( winNode ) + (FMCGetClientWidth( winNode, false ) / 2);
  945.     var centerY    = FMCGetScrollTop( winNode ) + (FMCGetClientHeight( winNode, false ) / 2);
  946.     
  947.     return [centerX, centerY];
  948. }
  949.  
  950. function FMCGetScrollHeight( winNode )
  951. {
  952.     var scrollHeight    = null;
  953.     
  954.     if ( winNode.document.scrollHeight )
  955.     {
  956.         scrollHeight = winNode.document.scrollHeight;
  957.     }
  958.     else if ( FMCIsIE55() || (winNode.document.compatMode && winNode.document.compatMode == "BackCompat") )
  959.     {
  960.         scrollHeight = winNode.document.body.scrollHeight;
  961.     }
  962.     else if ( winNode.document.documentElement )
  963.     {
  964.         scrollHeight = winNode.document.documentElement.scrollHeight;
  965.     }
  966.     
  967.     return scrollHeight;
  968. }
  969.  
  970. function FMCGetScrollWidth( winNode )
  971. {
  972.     var scrollWidth = null;
  973.     
  974.     if ( winNode.document.scrollWidth )
  975.     {
  976.         scrollWidth = winNode.document.scrollWidth;
  977.     }
  978.     else if ( FMCIsIE55() || (winNode.document.compatMode && winNode.document.compatMode == "BackCompat") )
  979.     {
  980.         scrollWidth = winNode.document.body.scrollWidth;
  981.     }
  982.     else if ( winNode.document.documentElement )
  983.     {
  984.         scrollWidth = winNode.document.documentElement.scrollWidth;
  985.     }
  986.     
  987.     return scrollWidth;
  988. }
  989.  
  990. function FMCGetScrollTop( winNode )
  991. {
  992.     var scrollTop   = null;
  993.     
  994.     if ( FMCIsSafari() )
  995.     {
  996.         scrollTop = winNode.document.body.scrollTop;
  997.     }
  998.     else if ( FMCIsIE55() || (winNode.document.compatMode && winNode.document.compatMode == "BackCompat") )
  999.     {
  1000.         scrollTop = winNode.document.body.scrollTop;
  1001.     }
  1002.     else if ( winNode.document.documentElement )
  1003.     {
  1004.         scrollTop = winNode.document.documentElement.scrollTop;
  1005.     }
  1006.     
  1007.     return scrollTop;
  1008. }
  1009.  
  1010. function FMCSetScrollTop( winNode, value )
  1011. {
  1012.     if ( FMCIsSafari() )
  1013.     {
  1014.         winNode.document.body.scrollTop = value;
  1015.     }
  1016.     else if ( FMCIsIE55() || (winNode.document.compatMode && winNode.document.compatMode == "BackCompat") )
  1017.     {
  1018.         winNode.document.body.scrollTop = value;
  1019.     }
  1020.     else if ( winNode.document.documentElement )
  1021.     {
  1022.         winNode.document.documentElement.scrollTop = value;
  1023.     }
  1024. }
  1025.  
  1026. function FMCGetScrollLeft( winNode )
  1027. {
  1028.     var scrollLeft  = null;
  1029.     
  1030.     if ( FMCIsSafari() )
  1031.     {
  1032.         scrollLeft = winNode.document.body.scrollLeft;
  1033.     }
  1034.     else if ( FMCIsIE55() || (winNode.document.compatMode && winNode.document.compatMode == "BackCompat") )
  1035.     {
  1036.         scrollLeft = winNode.document.body.scrollLeft;
  1037.     }
  1038.     else if ( winNode.document.documentElement )
  1039.     {
  1040.         scrollLeft = winNode.document.documentElement.scrollLeft;
  1041.     }
  1042.     
  1043.     return scrollLeft;
  1044. }
  1045.  
  1046. function FMCSetScrollLeft( winNode, value )
  1047. {
  1048.     if ( FMCIsSafari() )
  1049.     {
  1050.         winNode.document.body.scrollLeft = value;
  1051.     }
  1052.     else if ( FMCIsIE55() || (winNode.document.compatMode && winNode.document.compatMode == "BackCompat") )
  1053.     {
  1054.         winNode.document.body.scrollLeft = value;
  1055.     }
  1056.     else if ( winNode.document.documentElement )
  1057.     {
  1058.         winNode.document.documentElement.scrollLeft = value;
  1059.     }
  1060. }
  1061.  
  1062. function FMCGetClientX( winNode, e )
  1063. {
  1064.     var clientX;
  1065.     
  1066.     if ( typeof( e.pageX ) != "undefined" )
  1067.     {
  1068.         clientX = e.pageX - FMCGetScrollLeft( winNode );
  1069.     }
  1070.     else if ( typeof( e.clientX ) != "undefined" )
  1071.     {
  1072.         clientX = e.clientX;
  1073.     }
  1074.     
  1075.     return clientX;
  1076. }
  1077.  
  1078. function FMCGetClientY( winNode, e )
  1079. {
  1080.     var clientY;
  1081.     
  1082.     if ( typeof( e.pageY ) != "undefined" )
  1083.     {
  1084.         clientY = e.pageY - FMCGetScrollTop( winNode );
  1085.     }
  1086.     else if ( typeof( e.clientY ) != "undefined" )
  1087.     {
  1088.         clientY = e.clientY;
  1089.     }
  1090.     
  1091.     return clientY;
  1092. }
  1093.  
  1094. function FMCGetPageX( winNode, e )
  1095. {
  1096.     var pageX;
  1097.     
  1098.     if ( typeof( e.pageX ) != "undefined" )
  1099.     {
  1100.         pageX = e.pageX;
  1101.     }
  1102.     else if ( typeof( e.clientX ) != "undefined" )
  1103.     {
  1104.         pageX = e.clientX + FMCGetScrollLeft( winNode );
  1105.     }
  1106.     
  1107.     return pageX;
  1108. }
  1109.  
  1110. function FMCGetPageY( winNode, e )
  1111. {
  1112.     var pageY;
  1113.     
  1114.     if ( typeof( e.pageY ) != "undefined" )
  1115.     {
  1116.         pageY = e.pageY;
  1117.     }
  1118.     else if ( typeof( e.clientY ) != "undefined" )
  1119.     {
  1120.         pageY = e.clientY + FMCGetScrollTop( winNode );
  1121.     }
  1122.     
  1123.     return pageY;
  1124. }
  1125.  
  1126. function FMCGetMouseXRelativeTo( winNode, e, el )
  1127. {
  1128.     var mouseX    = FMCGetPageX( winNode, e, el );
  1129.     var elX        = FMCGetPosition( el )[1];
  1130.     var x        = mouseX - elX;
  1131.  
  1132.     return x;
  1133. }
  1134.  
  1135. function FMCGetMouseYRelativeTo( winNode, e, el )
  1136. {
  1137.     var mouseY    = FMCGetPageY( winNode, e, el );
  1138.     var elY        = FMCGetPosition( el )[0];
  1139.     var y        = mouseY - elY;
  1140.  
  1141.     return y;
  1142. }
  1143.  
  1144. function FMCGetPosition( node )
  1145. {
  1146.     var topPos    = 0;
  1147.     var leftPos    = 0;
  1148.     
  1149.     if ( node.offsetParent )
  1150.     {
  1151.         topPos = node.offsetTop;
  1152.         leftPos = node.offsetLeft;
  1153.         
  1154.         while ( node = node.offsetParent )
  1155.         {
  1156.             topPos += node.offsetTop;
  1157.             leftPos += node.offsetLeft;
  1158.         }
  1159.     }
  1160.     
  1161.     return [topPos, leftPos];
  1162. }
  1163.  
  1164. function FMCScrollToVisible( win, node )
  1165. {
  1166.     var offset            = 0;
  1167.     
  1168.     if ( typeof( window.innerWidth ) != "undefined" && !FMCIsSafari() )
  1169.     {
  1170.         offset = 19;
  1171.     }
  1172.     
  1173.     var scrollTop        = FMCGetScrollTop( win );
  1174.     var scrollBottom    = scrollTop + FMCGetClientHeight( win, false ) - offset;
  1175.     var scrollLeft        = FMCGetScrollLeft( win );
  1176.     var scrollRight        = scrollLeft + FMCGetClientWidth( win, false ) - offset;
  1177.     
  1178.     var nodePos            = FMCGetPosition( node );
  1179.     var nodeTop            = nodePos[0];
  1180.     var nodeLeft        = parseInt( node.style.textIndent ) + nodePos[1];
  1181.     var nodeHeight        = node.offsetHeight;
  1182.     var nodeWidth        = node.getElementsByTagName( "a" )[0].offsetWidth;
  1183.     
  1184.     if ( nodeTop < scrollTop )
  1185.     {
  1186.         FMCSetScrollTop( win, nodeTop );
  1187.     }
  1188.     else if ( nodeTop + nodeHeight > scrollBottom )
  1189.     {
  1190.         FMCSetScrollTop( win, Math.min( nodeTop, nodeTop + nodeHeight - FMCGetClientHeight( win, false ) + offset ) );
  1191.     }
  1192.     
  1193.     if ( nodeLeft < scrollLeft )
  1194.     {
  1195.         FMCSetScrollLeft( win, nodeLeft );
  1196.     }
  1197.     else if ( nodeLeft + nodeWidth > scrollRight )
  1198.     {
  1199.         FMCSetScrollLeft( win, Math.min( nodeLeft, nodeLeft + nodeWidth - FMCGetClientWidth( win, false ) + offset ) );
  1200.     }
  1201. }
  1202.  
  1203. function FMCGetComputedStyle( node, style )
  1204. {
  1205.     var value   = null;
  1206.     
  1207.     if ( node.currentStyle )
  1208.     {
  1209.         value = node.currentStyle[style];
  1210.     }
  1211.     else if ( document.defaultView && document.defaultView.getComputedStyle )
  1212.     {
  1213.         var computedStyle    = document.defaultView.getComputedStyle( node, null );
  1214.         
  1215.         if ( computedStyle )
  1216.         {
  1217.             value = computedStyle[style];
  1218.         }
  1219.     }
  1220.     
  1221.     return value;
  1222. }
  1223.  
  1224. function FMCConvertToPx( doc, str, dimension, defaultValue )
  1225. {
  1226.     if ( !str || str.charAt( 0 ) == "-" )
  1227.     {
  1228.         return defaultValue;
  1229.     }
  1230.     
  1231.     if ( str.charAt( str.length - 1 ) == "\%" )
  1232.     {
  1233.         switch (dimension)
  1234.         {
  1235.             case "Width":
  1236.                 return parseInt( str ) * screen.width / 100;
  1237.                 
  1238.                 break;
  1239.             case "Height":
  1240.                 return parseInt( str ) * screen.height / 100;
  1241.                 
  1242.                 break;
  1243.         }
  1244.     }
  1245.     else
  1246.     {
  1247.         if ( parseInt( str ).toString() == str )
  1248.         {
  1249.             str += "px";
  1250.         }
  1251.     }
  1252.     
  1253.     try
  1254.     {
  1255.         var div    = doc.createElement( "div" );
  1256.     }
  1257.     catch ( err )
  1258.     {
  1259.         return defaultValue;
  1260.     }
  1261.     
  1262.     doc.body.appendChild( div );
  1263.     
  1264.     var value    = defaultValue;
  1265.     
  1266.     try
  1267.     {
  1268.         div.style.width = str;
  1269.         
  1270.         if ( div.currentStyle )
  1271.         {
  1272.             value = div.offsetWidth;
  1273.         }
  1274.         else if ( document.defaultView && document.defaultView.getComputedStyle )
  1275.         {
  1276.             value = parseInt( FMCGetComputedStyle( div, "width" ) );
  1277.         }
  1278.     }
  1279.     catch ( err )
  1280.     {
  1281.     }
  1282.     
  1283.     doc.body.removeChild( div );
  1284.     
  1285.     return value;
  1286. }
  1287.  
  1288. function FMCGetOpacity( el )
  1289. {
  1290.     var opacity    = 0;
  1291.     
  1292.     if ( el.filters )
  1293.     {
  1294.         opacity = parseInt( el.style.filter.substring( 17, el.style.filter.length - 2 ) );
  1295.     }
  1296.     else if ( el.style.MozOpacity != null )
  1297.     {
  1298.         opacity = parseFloat( el.style.MozOpacity ) * 100;
  1299.     }
  1300.     
  1301.     return opacity;
  1302. }
  1303.  
  1304. function FMCSetOpacity( el, opacityPercent )
  1305. {
  1306.     if ( el.filters )
  1307.     {
  1308.         el.style.filter = "alpha( opacity = " + opacityPercent + " )";
  1309.     }
  1310.     else if ( el.style.MozOpacity != null )
  1311.     {
  1312.         el.style.MozOpacity = opacityPercent / 100;
  1313.     }
  1314. }
  1315.  
  1316. function FMCToggleDisplay( el )
  1317. {
  1318.     if ( el.style.display == "none" )
  1319.     {
  1320.         el.style.display = "";
  1321.     }
  1322.     else
  1323.     {
  1324.         el.style.display = "none";
  1325.     }
  1326. }
  1327.  
  1328. function FMCIsChildNode( childNode, parentNode )
  1329. {
  1330.     var    doc    = parentNode.ownerDocument;
  1331.     
  1332.     if ( childNode == null )
  1333.     {
  1334.         return null;
  1335.     }
  1336.     
  1337.     for ( var currNode = childNode; ; currNode = currNode.parentNode )
  1338.     {
  1339.         if ( currNode == parentNode )
  1340.         {
  1341.             return true;
  1342.         }
  1343.         
  1344.         if ( currNode == doc.body )
  1345.         {
  1346.             return false;
  1347.         }
  1348.     }
  1349. }
  1350.  
  1351. function FMCStripCssUrl( url )
  1352. {
  1353.     if ( !url )
  1354.     {
  1355.         return null;
  1356.     }
  1357.     
  1358.     var regex    = /url\(\s*(['\"]?)([^'\"\s]*)\1\s*\)/;
  1359.     var match    = regex.exec( url );
  1360.     
  1361.     if ( match )
  1362.     {
  1363.         return match[2];
  1364.     }
  1365.     
  1366.     return null;
  1367. }
  1368.  
  1369. function FMCCreateCssUrl( path )
  1370. {
  1371.     return "url(\"" + path + "\")";
  1372. }
  1373.  
  1374. function FMCGetPropertyValue( propertyNode, defaultValue )
  1375. {
  1376.     var propValue    = defaultValue;
  1377.     var valueNode    = propertyNode.firstChild;
  1378.     
  1379.     if ( valueNode )
  1380.     {
  1381.         propValue = valueNode.nodeValue;
  1382.     }
  1383.     
  1384.     return propValue;
  1385. }
  1386.  
  1387. function FMCParseInt( str, defaultValue )
  1388. {
  1389.     var num    = parseInt( str );
  1390.  
  1391.     if ( num.toString() == "NaN" )
  1392.     {
  1393.         num = defaultValue;
  1394.     }
  1395.     
  1396.     return num;
  1397. }
  1398.  
  1399. function FMCConvertBorderToPx( doc, value )
  1400. {
  1401.     var newValue    = "";
  1402.     var valueParts    = value.split( " " );
  1403.  
  1404.     for ( var i = 0; i < valueParts.length; i++ )
  1405.     {
  1406.         var currPart    = valueParts[i];
  1407.         
  1408.         if ( i == 1 )
  1409.         {
  1410.             currPart = FMCConvertToPx( doc, currPart, null, currPart );
  1411.             
  1412.             if ( parseInt( currPart ).toString() == currPart )
  1413.             {
  1414.                 currPart += "px";
  1415.             }
  1416.         }
  1417.  
  1418.         newValue += (((i > 0) ? " " : "") + currPart);
  1419.     }
  1420.     
  1421.     return newValue;
  1422. }
  1423.  
  1424. function FMCUnhide( win, node )
  1425. {
  1426.     for ( var currNode = node.parentNode; currNode.nodeName != "BODY"; currNode = currNode.parentNode )
  1427.     {
  1428.         if ( currNode.style.display == "none" )
  1429.         {
  1430.             var classRoot   = FMCContainsClassRoot( currNode.className, "MCExpandingBody", "MCDropDownBody", "MCTextPopupBody" );
  1431.             
  1432.             if ( classRoot == "MCExpandingBody" )
  1433.             {
  1434.                 win.FMCExpand( currNode.parentNode.getElementsByTagName("a")[0] );
  1435.             }
  1436.             else if ( classRoot == "MCDropDownBody" )
  1437.             {
  1438.                 var dropDownBodyID  = currNode.id.substring( "MCDropDownBody".length + 1, currNode.id.length );
  1439.                 var aNodes          = currNode.parentNode.getElementsByTagName( "a" );
  1440.                 
  1441.                 for ( var i = 0; i < aNodes.length; i++ )
  1442.                 {
  1443.                     var aNode   = aNodes[i];
  1444.                     
  1445.                     if ( aNode.id.substring( "MCDropDownHotSpot".length + 1, aNode.id.length ) == dropDownBodyID )
  1446.                     {
  1447.                         win.FMCDropDown( aNode );
  1448.                     }
  1449.                 }
  1450.             }
  1451.             else if ( FMCGetMCAttribute( currNode, "MadCap:targetName" ) )
  1452.             {
  1453.                 var targetName      = FMCGetMCAttribute( currNode, "MadCap:targetName" );
  1454.                 var togglerNodes    = FMCGetElementsByClassRoot( win.document.body, "MCToggler" );
  1455.                 
  1456.                 for ( var i = 0; i < togglerNodes.length; i++ )
  1457.                 {
  1458.                     var targets = FMCGetMCAttribute( togglerNodes[i], "MadCap:targets" ).split( ";" );
  1459.                     var found   = false;
  1460.                     
  1461.                     for ( var j = 0; j < targets.length; j++ )
  1462.                     {
  1463.                         if ( targets[j] == targetName )
  1464.                         {
  1465.                             found = true;
  1466.                             
  1467.                             break;
  1468.                         }
  1469.                     }
  1470.                     
  1471.                     if ( !found )
  1472.                     {
  1473.                         continue;
  1474.                     }
  1475.                     
  1476.                     win.FMCToggler( togglerNodes[i] );
  1477.                     
  1478.                     break;
  1479.                 }
  1480.             }
  1481.             else if ( classRoot == "MCTextPopupBody" )
  1482.             {
  1483.                 continue;
  1484.             }
  1485.             else
  1486.             {
  1487.                 currNode.style.display = "";
  1488.             }
  1489.         }
  1490.     }
  1491. }
  1492.  
  1493. function StartLoading( win, parentElement, loadingLabel, loadingAltText, fadeElement )
  1494. {
  1495.     if ( !win.MCLoadingCount )
  1496.     {
  1497.         win.MCLoadingCount = 0;
  1498.     }
  1499.     
  1500.     win.MCLoadingCount++;
  1501.     
  1502.     if ( win.MCLoadingCount > 1 )
  1503.     {
  1504.         return;
  1505.     }
  1506.     
  1507.     //
  1508.     
  1509.     if ( fadeElement )
  1510.     {
  1511.         // IE bug: This causes the tab outline not to show and also causes the TOC entry fonts to look bold.
  1512.         //    if ( fadeElement.filters )
  1513.         //    {
  1514.         //        fadeElement.style.filter = "alpha( opacity = 10 )";
  1515.         //    }
  1516.         /*else*/ if ( fadeElement.style.MozOpacity != null )
  1517.         {
  1518.             fadeElement.style.MozOpacity = "0.1";
  1519.         }
  1520.     }
  1521.  
  1522.     var span        = win.document.createElement( "span" );
  1523.     var img            = win.document.createElement( "img" );
  1524.     var midPointX    = FMCGetScrollLeft( win ) + FMCGetClientWidth( win, false ) / 2;
  1525.     var spacing        = 3;
  1526.  
  1527.     parentElement.appendChild( span );
  1528.  
  1529.     span.id = "LoadingText";
  1530.     span.appendChild( win.document.createTextNode( loadingLabel ) );
  1531.     span.style.fontFamily = "Tahoma, Sans-Serif";
  1532.     span.style.fontSize = "9px";
  1533.     span.style.fontWeight = "bold";
  1534.     span.style.position = "absolute";
  1535.     span.style.left = (midPointX - (span.offsetWidth / 2)) + "px";
  1536.  
  1537.     var rootFrame    = FMCGetRootFrame();
  1538.     
  1539.     img.id = "LoadingImage";
  1540.     img.src = rootFrame.gRootFolder + MCGlobals.SkinTemplateFolder + "Images/Loading.gif";
  1541.     img.alt = loadingAltText;
  1542.     img.style.width = "70px";
  1543.     img.style.height = "13px";
  1544.     img.style.position = "absolute";
  1545.     img.style.left = (midPointX - (70/2)) + "px";
  1546.  
  1547.     var totalHeight    = span.offsetHeight + spacing + parseInt( img.style.height );
  1548.     var spanTop        = (FMCGetScrollTop( win ) + (FMCGetClientHeight( win, false ) - totalHeight)) / 2;
  1549.  
  1550.     span.style.top = spanTop + "px";
  1551.     img.style.top = spanTop + span.offsetHeight + spacing + "px";
  1552.  
  1553.     parentElement.appendChild( img );
  1554. }
  1555.  
  1556. function EndLoading( win, fadeElement )
  1557. {
  1558.     win.MCLoadingCount--;
  1559.     
  1560.     if ( win.MCLoadingCount > 0 )
  1561.     {
  1562.         return;
  1563.     }
  1564.     
  1565.     //
  1566.     
  1567.     var span    = win.document.getElementById( "LoadingText" );
  1568.     var img        = win.document.getElementById( "LoadingImage" );
  1569.  
  1570.     span.parentNode.removeChild( span );
  1571.     img.parentNode.removeChild( img );
  1572.  
  1573.     if ( fadeElement )
  1574.     {
  1575.         // IE bug: This causes the tab outline not to show and also causes the TOC entry fonts to look bold.
  1576.         //    if ( fadeElement.filters )
  1577.         //    {
  1578.         //        fadeElement.style.filter = "alpha( opacity = 100 )";
  1579.         //    }
  1580.         /*else*/ if ( fadeElement.style.MozOpacity != null )
  1581.         {
  1582.             fadeElement.style.MozOpacity = "1.0";
  1583.         }
  1584.     }
  1585. }
  1586.  
  1587. var gCallbacks        = new Array();
  1588. var gCallbackArgs    = new Array();
  1589.  
  1590. var MCEventType    = new Object();
  1591.  
  1592. MCEventType.OnLoad    = 0;
  1593. MCEventType.OnInit    = 1;
  1594. MCEventType.OnReady    = 2;
  1595.  
  1596. function FMCRegisterCallback( frameName, eventType, CallbackFunc, callbackArgs )
  1597. {
  1598.     var numCallbacks    = gCallbacks.length;
  1599.     var funcName        = "FMCCheck" + frameName;
  1600.     
  1601.     switch ( eventType )
  1602.     {
  1603.         case MCEventType.OnLoad:
  1604.             funcName = funcName + "Loaded";
  1605.             
  1606.             break;
  1607.         
  1608.         case MCEventType.OnInit:
  1609.             funcName = funcName + "Initialized";
  1610.             
  1611.             break;
  1612.             
  1613.         case MCEventType.OnReady:
  1614.             funcName = funcName + "Ready";
  1615.             
  1616.             break;
  1617.     }
  1618.  
  1619.     gCallbacks[numCallbacks] = CallbackFunc;
  1620.     gCallbackArgs[numCallbacks] = callbackArgs;
  1621.     
  1622.     setTimeout( funcName + "( " + numCallbacks + " );", 1 );
  1623. }
  1624.  
  1625. function FMCCheckMCGlobalsInitialized( index )
  1626. {
  1627.     if ( MCGlobals.Initialized )
  1628.     {
  1629.         gCallbacks[index]( gCallbackArgs[index] );
  1630.     }
  1631.     else
  1632.     {
  1633.         setTimeout( "FMCCheckMCGlobalsInitialized( " + index + " );", 1 );
  1634.     }
  1635. }
  1636.  
  1637. function FMCCheckRootReady( index )
  1638. {
  1639.     if ( MCGlobals.RootFrame.gReady )
  1640.     {
  1641.         gCallbacks[index]( gCallbackArgs[index] );
  1642.     }
  1643.     else
  1644.     {
  1645.         setTimeout( "FMCCheckRootReady( " + index + " );", 1 );
  1646.     }
  1647. }
  1648.  
  1649. function FMCCheckRootLoaded( index )
  1650. {
  1651.     if ( MCGlobals.RootFrame.gLoaded )
  1652.     {
  1653.         gCallbacks[index]( gCallbackArgs[index] );
  1654.     }
  1655.     else
  1656.     {
  1657.         setTimeout( "FMCCheckRootLoaded( " + index + " );", 1 );
  1658.     }
  1659. }
  1660.  
  1661. function FMCCheckTOCInitialized( index )
  1662. {
  1663.     if ( MCGlobals.NavigationFrame.frames["toc"].gInit )
  1664.     {
  1665.         gCallbacks[index]( gCallbackArgs[index] );
  1666.     }
  1667.     else
  1668.     {
  1669.         setTimeout( "FMCCheckTOCInitialized( " + index + " );", 1 );
  1670.     }
  1671. }
  1672.  
  1673. function FMCCheckSearchInitialized( index )
  1674. {
  1675.     if ( MCGlobals.NavigationFrame.frames["search"].gInit )
  1676.     {
  1677.         gCallbacks[index]( gCallbackArgs[index] );
  1678.     }
  1679.     else
  1680.     {
  1681.         setTimeout( "FMCCheckSearchInitialized( " + index + " );", 1 );
  1682.     }
  1683. }
  1684.  
  1685. function FMCCheckTopicCommentsLoaded( index )
  1686. {
  1687.     if ( MCGlobals.TopicCommentsFrame.gLoaded )
  1688.     {
  1689.         gCallbacks[index]( gCallbackArgs[index] );
  1690.     }
  1691.     else
  1692.     {
  1693.         setTimeout( "FMCCheckTopicCommentsLoaded( " + index + " );", 1 );
  1694.     }
  1695. }
  1696.  
  1697. function FMCCheckTopicCommentsInitialized( index )
  1698. {
  1699.     if ( MCGlobals.TopicCommentsFrame.gInit )
  1700.     {
  1701.         gCallbacks[index]( gCallbackArgs[index] );
  1702.     }
  1703.     else
  1704.     {
  1705.         setTimeout( "FMCCheckTopicCommentsInitialized( " + index + " );", 1 );
  1706.     }
  1707. }
  1708.  
  1709. function FMCCheckBodyCommentsLoaded( index )
  1710. {
  1711.     if ( MCGlobals.BodyCommentsFrame.gLoaded )
  1712.     {
  1713.         gCallbacks[index]( gCallbackArgs[index] );
  1714.     }
  1715.     else
  1716.     {
  1717.         setTimeout( "FMCCheckBodyCommentsLoaded( " + index + " );", 1 );
  1718.     }
  1719. }
  1720.  
  1721. function FMCCheckBodyCommentsInitialized( index )
  1722. {
  1723.     if ( MCGlobals.BodyCommentsFrame.gInit )
  1724.     {
  1725.         gCallbacks[index]( gCallbackArgs[index] );
  1726.     }
  1727.     else
  1728.     {
  1729.         setTimeout( "FMCCheckBodyCommentsInitialized( " + index + " );", 1 );
  1730.     }
  1731. }
  1732.  
  1733. function FMCCheckToolbarInitialized( index )
  1734. {
  1735.     if ( MCGlobals.ToolbarFrame.gInit )
  1736.     {
  1737.         gCallbacks[index]( gCallbackArgs[index] );
  1738.     }
  1739.     else
  1740.     {
  1741.         setTimeout( "FMCCheckToolbarInitialized( " + index + " );", 1 );
  1742.     }
  1743. }
  1744.  
  1745. function FMCCheckNavigationReady( index )
  1746. {
  1747.     if ( MCGlobals.NavigationFrame.gReady )
  1748.     {
  1749.         gCallbacks[index]( gCallbackArgs[index] );
  1750.     }
  1751.     else
  1752.     {
  1753.         setTimeout( "FMCCheckNavigationReady( " + index + " );", 1 );
  1754.     }
  1755. }
  1756.  
  1757. function FMCCheckNavigationLoaded( index )
  1758. {
  1759.     if ( MCGlobals.NavigationFrame.gLoaded )
  1760.     {
  1761.         gCallbacks[index]( gCallbackArgs[index] );
  1762.     }
  1763.     else
  1764.     {
  1765.         setTimeout( "FMCCheckNavigationLoaded( " + index + " );", 1 );
  1766.     }
  1767. }
  1768.  
  1769. function FMCCheckBodyReady( index )
  1770. {
  1771.     if ( typeof( MCGlobals.BodyFrame.gReady ) == "undefined" || MCGlobals.BodyFrame.gReady )
  1772.     {
  1773.         gCallbacks[index]( gCallbackArgs[index] );
  1774.     }
  1775.     else
  1776.     {
  1777.         setTimeout( "FMCCheckBodyReady( " + index + " );", 1 );
  1778.     }
  1779. }
  1780.  
  1781. function FMCCheckBodyLoaded( index )
  1782. {
  1783.     if ( MCGlobals.BodyFrame.gLoaded )
  1784.     {
  1785.         gCallbacks[index]( gCallbackArgs[index] );
  1786.     }
  1787.     else
  1788.     {
  1789.         setTimeout( "FMCCheckBodyLoaded( " + index + " );", 1 );
  1790.     }
  1791. }
  1792.  
  1793. function FMCCheckPersistenceInitialized( index )
  1794. {
  1795.     if ( MCGlobals.PersistenceFrame.gInit )
  1796.     {
  1797.         gCallbacks[index]( gCallbackArgs[index] );
  1798.     }
  1799.     else
  1800.     {
  1801.         setTimeout( "FMCCheckPersistenceInitialized( " + index + " );", 1 );
  1802.     }
  1803. }
  1804.  
  1805. function FMCSortStringArray( stringArray )
  1806. {
  1807.     stringArray.sort( FMCCompareStrings );
  1808. }
  1809.  
  1810. function FMCCompareStrings( a, b )
  1811. {
  1812.     var ret;
  1813.  
  1814.     if ( a.toLowerCase() < b.toLowerCase() )
  1815.     {
  1816.         ret = -1;
  1817.     }
  1818.     else if ( a.toLowerCase() == b.toLowerCase() )
  1819.     {
  1820.         ret = 0;
  1821.     }
  1822.     else if ( a.toLowerCase() > b.toLowerCase() )
  1823.     {
  1824.         ret = 1;
  1825.     }
  1826.  
  1827.     return ret;
  1828. }
  1829.  
  1830. function FMCSetCookie( name, value, days )
  1831. {
  1832.     if ( window != MCGlobals.NavigationFrame )
  1833.     {
  1834.         MCGlobals.NavigationFrame.FMCSetCookie( name, value, days );
  1835.         
  1836.         return;
  1837.     }
  1838.     
  1839.     value = encodeURI( value );
  1840.     
  1841.     if ( days )
  1842.     {
  1843.         var date    = new Date();
  1844.         
  1845.         date.setTime( date.getTime() + (1000 * 60 * 60 * 24 * days) );
  1846.         
  1847.         var expires    = "; expires=" + date.toGMTString();
  1848.     }
  1849.     else
  1850.     {
  1851.         var expires    = "";
  1852.     }
  1853.  
  1854.     var rootFrame    = FMCGetRootFrame();
  1855.     var navFrame    = rootFrame.frames["navigation"];
  1856.     var path        = FMCGetPathnameFolder( navFrame.document.location );
  1857.  
  1858.     //navFrame.document.cookie = name + "=" + value + expires + ";" + " path=" + path + ";";
  1859.     navFrame.document.cookie = name + "=" + value + expires + ";";
  1860. }
  1861.  
  1862. function FMCReadCookie( name )
  1863. {
  1864.     var value        = null;
  1865.     var nameEq        = name + "=";
  1866.     var rootFrame    = FMCGetRootFrame();
  1867.     var navFrame    = rootFrame.frames["navigation"];
  1868.     var cookies        = navFrame.document.cookie.split( ";" );
  1869.  
  1870.     for ( var i = 0; i < cookies.length; i++ )
  1871.     {
  1872.         var cookie    = cookies[i];
  1873.         
  1874.         cookie = FMCTrim( cookie );
  1875.         
  1876.         if ( cookie.indexOf( nameEq ) == 0 )
  1877.         {
  1878.             value = cookie.substring( nameEq.length, cookie.length );
  1879.             value = decodeURI( value );
  1880.             
  1881.             break;
  1882.         }
  1883.     }
  1884.  
  1885.     return value;
  1886. }
  1887.  
  1888. function FMCRemoveCookie( name )
  1889. {
  1890.     FMCSetCookie( name, "", -1 );
  1891. }
  1892.  
  1893. function FMCLoadUserData( name )
  1894. {
  1895.     var persistFrame    = MCGlobals.PersistenceFrame;
  1896.     var persistDiv        = persistFrame.document.getElementById( "Persist" );
  1897.     
  1898.     persistDiv.load( "MCXMLStore" );
  1899.     
  1900.     var value    = persistDiv.getAttribute( name );
  1901.     
  1902.     return value;
  1903. }
  1904.  
  1905. function FMCSaveUserData( name, value )
  1906. {
  1907.     var persistFrame    = MCGlobals.PersistenceFrame;
  1908.     var persistDiv        = persistFrame.document.getElementById( "Persist" );
  1909.     
  1910.     persistDiv.setAttribute( name, value );
  1911.     persistDiv.save( "MCXMLStore" );
  1912. }
  1913.  
  1914. function FMCRemoveUserData( name )
  1915. {
  1916.     var persistFrame    = MCGlobals.PersistenceFrame;
  1917.     var persistDiv        = persistFrame.document.getElementById( "Persist" );
  1918.     
  1919.     persistDiv.removeAttribute( name );
  1920.     persistDiv.save( "MCXMLStore" );
  1921. }
  1922.  
  1923. function FMCInsertOpacitySheet( winNode, color )
  1924. {
  1925.     var div        = winNode.document.createElement( "div" );
  1926.     var style    = div.style;
  1927.     
  1928.     div.id = "MCOpacitySheet";
  1929.     style.position = "absolute";
  1930.     style.top = FMCGetScrollTop( winNode ) + "px";
  1931.     style.left = FMCGetScrollLeft( winNode ) + "px";
  1932.     style.width = FMCGetClientWidth( winNode, false ) + "px";
  1933.     style.height = FMCGetClientHeight( winNode, false ) + "px";
  1934.     style.backgroundColor = color;
  1935.     style.zIndex = "100";
  1936.     
  1937.     winNode.document.body.appendChild( div );
  1938.     
  1939.     FMCSetOpacity( div, 75 );
  1940. }
  1941.  
  1942. function FMCRemoveOpacitySheet( winNode )
  1943. {
  1944.     var div    = winNode.document.getElementById( "MCOpacitySheet" );
  1945.     
  1946.     if ( !div )
  1947.     {
  1948.         return;
  1949.     }
  1950.     
  1951.     div.parentNode.removeChild( div );
  1952. }
  1953.  
  1954. function FMCSetupButtonFromStylesheet( tr, styleName, styleClassName, defaultOutPath, defaultOverPath, defaultSelectedPath, defaultWidth, defaultHeight, defaultTooltip, defaultLabel, OnClickHandler )
  1955. {
  1956.     var td                    = document.createElement( "td" );
  1957.     var outImagePath        = CMCFlareStylesheet.LookupValue( styleName, styleClassName, "Icon", null );
  1958.     var overImagePath        = CMCFlareStylesheet.LookupValue( styleName, styleClassName, "HoverIcon", null );
  1959.     var selectedImagePath    = CMCFlareStylesheet.LookupValue( styleName, styleClassName, "PressedIcon", null );
  1960.     
  1961.     if ( outImagePath == null )
  1962.     {
  1963.         outImagePath = defaultOutPath;
  1964.     }
  1965.     else
  1966.     {
  1967.         outImagePath = FMCStripCssUrl( outImagePath );
  1968.         outImagePath = MCGlobals.RootFolder + FMCGetSkinFolder() + outImagePath;
  1969.     }
  1970.     
  1971.     if ( overImagePath == null )
  1972.     {
  1973.         overImagePath = defaultOverPath;
  1974.     }
  1975.     else
  1976.     {
  1977.         overImagePath = FMCStripCssUrl( overImagePath );
  1978.         overImagePath = MCGlobals.RootFolder + FMCGetSkinFolder() + overImagePath;
  1979.     }
  1980.     
  1981.     if ( selectedImagePath == null )
  1982.     {
  1983.         selectedImagePath = defaultSelectedPath;
  1984.     }
  1985.     else
  1986.     {
  1987.         selectedImagePath = FMCStripCssUrl( selectedImagePath );
  1988.         selectedImagePath = MCGlobals.RootFolder + FMCGetSkinFolder() + selectedImagePath;
  1989.     }
  1990.  
  1991.     tr.appendChild( td );
  1992.     
  1993.     var title    = CMCFlareStylesheet.LookupValue( styleName, styleClassName, "Tooltip", defaultTooltip );
  1994.     var label    = CMCFlareStylesheet.LookupValue( styleName, styleClassName, "Label", defaultLabel );
  1995.     var width    = CMCFlareStylesheet.GetResourceProperty( outImagePath, "Width", defaultWidth );
  1996.     var height    = CMCFlareStylesheet.GetResourceProperty( outImagePath, "Height", defaultHeight );
  1997.     
  1998.     MakeButton( td, title, outImagePath, overImagePath, selectedImagePath, width, height, label );
  1999.     td.firstChild.onclick = OnClickHandler;
  2000. }
  2001.  
  2002. //
  2003. //    End helper functions
  2004. //
  2005.  
  2006. //
  2007. //    Class CMCXmlParser
  2008. //
  2009.  
  2010. function CMCXmlParser( args, LoadFunc )
  2011. {
  2012.     // Private member variables and functions
  2013.     
  2014.     var mSelf        = this;
  2015.     this.mXmlDoc    = null;
  2016.     this.mXmlHttp    = null;
  2017.     this.mArgs        = args;
  2018.     this.mLoadFunc    = LoadFunc;
  2019.     
  2020.     this.OnreadystatechangeLocal    = function()
  2021.     {
  2022.         if ( mSelf.mXmlDoc.readyState == 4 )
  2023.         {
  2024.             mSelf.mLoadFunc( mSelf.mXmlDoc, mSelf.mArgs );
  2025.         }
  2026.     };
  2027.     
  2028.     this.OnreadystatechangeRemote    = function()
  2029.     {
  2030.         if ( mSelf.mXmlHttp.readyState == 4 )
  2031.         {
  2032.             mSelf.mLoadFunc( mSelf.mXmlHttp.responseXML, mSelf.mArgs );
  2033.         }
  2034.     };
  2035. }
  2036.  
  2037. CMCXmlParser.prototype.LoadLocal    = function( xmlFile, async )
  2038. {
  2039.     if ( window.ActiveXObject )
  2040.     {
  2041.         this.mXmlDoc = new ActiveXObject( "Microsoft.XMLDOM" );
  2042.         this.mXmlDoc.async = async;
  2043.         
  2044.         if ( this.mLoadFunc )
  2045.         {
  2046.             this.mXmlDoc.onreadystatechange = this.OnreadystatechangeLocal;
  2047.         }
  2048.         
  2049.         try
  2050.         {
  2051.             if ( !this.mXmlDoc.load( xmlFile ) )
  2052.             {
  2053.                 this.mXmlDoc = null;
  2054.             }
  2055.         }
  2056.         catch ( err )
  2057.         {
  2058.             this.mXmlDoc = null;
  2059.         }
  2060.     }
  2061.     else if ( window.XMLHttpRequest )
  2062.     {
  2063.         this.LoadRemote( xmlFile, async ); // window.XMLHttpRequest also works on local files
  2064.     }
  2065.  
  2066.     return this.mXmlDoc;
  2067. };
  2068.  
  2069. CMCXmlParser.prototype.LoadRemote    = function( xmlFile, async )
  2070. {
  2071.     if ( window.ActiveXObject )
  2072.     {
  2073.         this.mXmlHttp = new ActiveXObject( "Msxml2.XMLHTTP" );
  2074.     }
  2075.     else if ( window.XMLHttpRequest )
  2076.     {
  2077.         xmlFile = xmlFile.replace( /;/g, "%3B" );   // For Safari
  2078.         this.mXmlHttp = new XMLHttpRequest();
  2079.     }
  2080.     
  2081.     if ( this.mLoadFunc )
  2082.     {
  2083.         this.mXmlHttp.onreadystatechange = this.OnreadystatechangeRemote;
  2084.     }
  2085.     
  2086.     this.mXmlHttp.open( "GET", xmlFile, async );
  2087.     
  2088.     try
  2089.     {
  2090.         this.mXmlHttp.send( null );
  2091.     }
  2092.     catch ( err )
  2093.     {
  2094.         this.mXmlHttp.abort();
  2095.     }
  2096.     
  2097.     if ( !async && (this.mXmlHttp.status == 0 || this.mXmlHttp.status == 200) )
  2098.     {
  2099.         this.mXmlDoc = this.mXmlHttp.responseXML;
  2100.     }
  2101.     
  2102.     return this.mXmlDoc;
  2103. };
  2104.  
  2105. // Public member functions
  2106.  
  2107. CMCXmlParser.prototype.Load    = function( xmlFile, async )
  2108. {
  2109.     var xmlDoc            = null;
  2110.     var protocolType    = document.location.protocol;
  2111.     
  2112.     if ( protocolType == "file:" || protocolType == "mk:" )
  2113.     {
  2114.         xmlDoc = this.LoadLocal( xmlFile, async );
  2115.     }
  2116.     else if ( protocolType == "http:" || protocolType == "https:" )
  2117.     {
  2118.         xmlDoc = this.LoadRemote( xmlFile, async );
  2119.     }
  2120.     
  2121.     return xmlDoc;
  2122. };
  2123.  
  2124. // Static member functions
  2125.  
  2126. CMCXmlParser.GetXmlDoc    = function( xmlFile, async, LoadFunc, args )
  2127. {
  2128.     var xmlParser    = new CMCXmlParser( args, LoadFunc );
  2129.     var xmlDoc        = xmlParser.Load( xmlFile, async );
  2130.     
  2131.     return xmlDoc;
  2132. }
  2133.  
  2134. CMCXmlParser.LoadXmlString    = function( xmlString )
  2135. {
  2136.     var xmlDoc    = null;
  2137.     
  2138.     if ( window.ActiveXObject )
  2139.     {
  2140.         xmlDoc = new ActiveXObject( "Microsoft.XMLDOM" );
  2141.         xmlDoc.async = false;
  2142.         xmlDoc.loadXML( xmlString );
  2143.     }
  2144.     else if ( DOMParser )
  2145.     {
  2146.         var parser    = new DOMParser();
  2147.         
  2148.         xmlDoc = parser.parseFromString( xmlString, "text/xml" );
  2149.     }
  2150.     
  2151.     return xmlDoc;
  2152. }
  2153.  
  2154. CMCXmlParser.CallWebService    = function( webServiceUrl, async, onCompleteFunc, onCompleteArgs )
  2155. {
  2156.     var xmlParser    = new CMCXmlParser( onCompleteArgs, onCompleteFunc );
  2157.     var xmlDoc        = xmlParser.LoadRemote( webServiceUrl, async );
  2158.     
  2159.     return xmlDoc;
  2160. }
  2161.  
  2162. //
  2163. //    End class CMCXmlParser
  2164. //
  2165.  
  2166. //
  2167. //    Class CMCFlareStylesheet
  2168. //
  2169.  
  2170. var CMCFlareStylesheet    = new function()
  2171. {
  2172.     // Private member variables
  2173.  
  2174.     var mInitialized            = false;
  2175.     var mXmlDoc                    = null;
  2176.     var mInitializedResources    = false;
  2177.     var mResourceMap            = null;
  2178.     
  2179.     // Private methods
  2180.     
  2181.     function Init()
  2182.     {
  2183.         mXmlDoc = CMCXmlParser.GetXmlDoc( MCGlobals.RootFolder + FMCGetSkinFolder() + "Stylesheet.xml", false, null, null );
  2184.         
  2185.         mInitialized = true;
  2186.     }
  2187.     
  2188.     function InitializeResources()
  2189.     {
  2190.         mInitializedResources = true;
  2191.         mResourceMap = new CMCDictionary();
  2192.         
  2193.         var styleDoc        = CMCXmlParser.GetXmlDoc( MCGlobals.RootFolder + FMCGetSkinFolder() + "Stylesheet.xml", false, null, null );
  2194.         var resourcesInfos    = styleDoc.getElementsByTagName( "ResourcesInfo" );
  2195.  
  2196.         if ( resourcesInfos.length > 0 )
  2197.         {
  2198.             var resources    = resourcesInfos[0].getElementsByTagName( "Resource" );
  2199.  
  2200.             for ( var i = 0; i < resources.length; i++ )
  2201.             {
  2202.                 var resource    = resources[i];
  2203.                 var properties    = new CMCDictionary();
  2204.                 var name        = resource.getAttribute( "Name" );
  2205.                 
  2206.                 if ( !name ) { continue; }
  2207.  
  2208.                 for ( var j = 0; j < resource.attributes.length; j++ )
  2209.                 {
  2210.                     var attribute    = resource.attributes[j];
  2211.                     
  2212.                     properties.Add( attribute.nodeName.toLowerCase(), attribute.nodeValue.toLowerCase() );
  2213.                 }
  2214.  
  2215.                 mResourceMap.Add( name, properties );
  2216.             }
  2217.         }
  2218.     }
  2219.     
  2220.     // Public methods
  2221.     
  2222.     this.LookupValue    = function( styleName, styleClassName, propertyName, defaultValue )
  2223.     {
  2224.         if ( !mInitialized )
  2225.         {
  2226.             Init();
  2227.             
  2228.             if ( mXmlDoc == null )
  2229.             {
  2230.                 return defaultValue;
  2231.             }
  2232.         }
  2233.         
  2234.         var value                = defaultValue;
  2235.         var styleNodes            = mXmlDoc.getElementsByTagName( "Style" );
  2236.         var styleNodesLength    = styleNodes.length;
  2237.         var styleNode            = null;
  2238.         
  2239.         for ( var i = 0; i < styleNodesLength; i++ )
  2240.         {
  2241.             if ( styleNodes[i].getAttribute( "Name" ) == styleName )
  2242.             {
  2243.                 styleNode = styleNodes[i];
  2244.                 break;
  2245.             }
  2246.         }
  2247.         
  2248.         if ( styleNode == null )
  2249.         {
  2250.             return value;
  2251.         }
  2252.         
  2253.         var styleClassNodes            = styleNode.getElementsByTagName( "StyleClass" );
  2254.         var styleClassNodesLength    = styleClassNodes.length;
  2255.         var styleClassNode            = null;
  2256.         
  2257.         for ( var i = 0; i < styleClassNodesLength; i++ )
  2258.         {
  2259.             if ( styleClassNodes[i].getAttribute( "Name" ) == styleClassName )
  2260.             {
  2261.                 styleClassNode = styleClassNodes[i];
  2262.                 break;
  2263.             }
  2264.         }
  2265.         
  2266.         if ( styleClassNode == null )
  2267.         {
  2268.             return value;
  2269.         }
  2270.         
  2271.         var propertyNodes        = styleClassNode.getElementsByTagName( "Property" );
  2272.         var propertyNodesLength    = propertyNodes.length;
  2273.         var propertyNode        = null;
  2274.         
  2275.         for ( var i = 0; i < propertyNodesLength; i++ )
  2276.         {
  2277.             if ( propertyNodes[i].getAttribute( "Name" ) == propertyName )
  2278.             {
  2279.                 propertyNode = propertyNodes[i];
  2280.                 break;
  2281.             }
  2282.         }
  2283.         
  2284.         if ( propertyNode == null )
  2285.         {
  2286.             return value;
  2287.         }
  2288.         
  2289.         value = propertyNode.firstChild.nodeValue;
  2290.         value = FMCTrim( value );
  2291.         
  2292.         return value;
  2293.     };
  2294.     
  2295.     this.GetResourceProperty    = function( name, property, defaultValue )
  2296.     {
  2297.         if ( !mInitialized )
  2298.         {
  2299.             Init();
  2300.             
  2301.             if ( mXmlDoc == null )
  2302.             {
  2303.                 return defaultValue;
  2304.             }
  2305.         }
  2306.         
  2307.         if ( !mInitializedResources )
  2308.         {
  2309.             InitializeResources();
  2310.         }
  2311.         
  2312.         var properties    = mResourceMap.GetItem( name );
  2313.  
  2314.         if ( !properties )
  2315.         {
  2316.             return defaultValue;
  2317.         }
  2318.  
  2319.         var propValue    = properties.GetItem( property.toLowerCase() );
  2320.  
  2321.         if ( !propValue )
  2322.         {
  2323.             return defaultValue;
  2324.         }
  2325.  
  2326.         return propValue;
  2327.     };
  2328.     
  2329.     this.SetImageFromStylesheet    = function( img, styleName, styleClassName, propertyName, defaultValue, defaultWidth, defaultHeight )
  2330.     {
  2331.         var value    = this.LookupValue( styleName, styleClassName, propertyName, null );
  2332.         var imgSrc    = null;
  2333.         
  2334.         if ( value == null )
  2335.         {
  2336.             value = defaultValue;
  2337.             imgSrc = value;
  2338.         }
  2339.         else
  2340.         {
  2341.             value = FMCStripCssUrl( value );
  2342.             value = decodeURIComponent( value );
  2343.             value = escape( value );
  2344.             imgSrc = MCGlobals.RootFolder + FMCGetSkinFolder() + value;
  2345.         }
  2346.         
  2347.         img.src = imgSrc;
  2348.         img.style.width = this.GetResourceProperty( value, "Width", defaultWidth ) + "px";
  2349.         img.style.height = this.GetResourceProperty( value, "Height", defaultHeight ) + "px";
  2350.     };
  2351. }
  2352.  
  2353. //
  2354. //    End class CMCFlareStylesheet
  2355. //
  2356.  
  2357. //
  2358. //    Class CMCDictionary
  2359. //
  2360.  
  2361. function CMCDictionary()
  2362. {
  2363.     // Public properties
  2364.     
  2365.     this.mMap    = new Array();
  2366.     this.mKeys    = new Array();
  2367. }
  2368.  
  2369. CMCDictionary.prototype.GetItem    = function( key )
  2370. {
  2371.     var item    = this.mMap["_" + key];
  2372.  
  2373.     if ( typeof( item ) == "undefined" )
  2374.     {
  2375.         item = null;
  2376.     }
  2377.  
  2378.     return item;
  2379. };
  2380.  
  2381. CMCDictionary.prototype.GetKeys    = function()
  2382. {
  2383.     return this.mKeys;
  2384. };
  2385.  
  2386. CMCDictionary.prototype.Remove    = function( key )
  2387. {
  2388.     delete( this.mMap["_" + key] );
  2389.     delete( this.mKeys[key] );
  2390. };
  2391.  
  2392. CMCDictionary.prototype.Add    = function( key, value )
  2393. {
  2394.     this.mMap["_" + key] = value;
  2395.     this.mKeys[key] = true;
  2396. };
  2397.  
  2398. CMCDictionary.prototype.AddUnique    = function( key, value )
  2399. {
  2400.     var savedValue    = this.mKeys[key];
  2401.     
  2402.     if ( typeof( savedValue ) == "undefined" || !savedValue )
  2403.     {
  2404.         this.Add( key, value );
  2405.     }
  2406. };
  2407.  
  2408. //
  2409. //    End class CMCDictionary
  2410. //
  2411.  
  2412. //
  2413. //    DOM traversal functions
  2414. //
  2415.  
  2416. function FMCGetElementsByClassRoot( node, classRoot )
  2417. {
  2418.     var nodes   = new Array();
  2419.     var args    = new Array();
  2420.     
  2421.     args[0] = nodes;
  2422.     args[1] = classRoot;
  2423.     
  2424.     FMCTraverseDOM( "post", node, FMCGetByClassRoot, args );
  2425.                          
  2426.     return nodes;
  2427. }
  2428.  
  2429. function FMCGetByClassRoot( node, args )
  2430. {
  2431.     var nodes       = args[0];
  2432.     var classRoot   = args[1];
  2433.     
  2434.     if ( node.nodeType == 1 && FMCContainsClassRoot( node.className, classRoot ) )
  2435.     {
  2436.         nodes[nodes.length] = node;
  2437.     }
  2438. }
  2439.  
  2440. function FMCGetElementsByAttribute( node, attribute, value )
  2441. {
  2442.     var nodes   = new Array();
  2443.     var args    = new Array();
  2444.     
  2445.     args[0] = nodes;
  2446.     args[1] = attribute;
  2447.     args[2] = value;
  2448.     
  2449.     FMCTraverseDOM( "post", node, FMCGetByAttribute, args );
  2450.                          
  2451.     return nodes;
  2452. }
  2453.  
  2454. function FMCGetByAttribute( node, args )
  2455. {
  2456.     var nodes       = args[0];
  2457.     var attribute   = args[1];
  2458.     var value       = args[2];
  2459.     
  2460.     try
  2461.     {
  2462.         if ( node.nodeType == 1 && (FMCGetMCAttribute( node, attribute ) == value || (value == "*" && FMCGetMCAttribute( node, attribute ))) )
  2463.         {
  2464.             nodes[nodes.length] = node;
  2465.         }
  2466.     }
  2467.     catch( err )
  2468.     {
  2469.         node.setAttribute( attribute, null );
  2470.     }
  2471. }
  2472.  
  2473. function FMCTraverseDOM( type, root, Func, args )
  2474. {
  2475.     if ( type == "pre" )
  2476.     {
  2477.         Func( root, args );
  2478.     }
  2479.     
  2480.     if ( root.childNodes.length != 0 )
  2481.     {
  2482.         for ( var i = 0; i < root.childNodes.length; i++ )
  2483.         {
  2484.             FMCTraverseDOM( type, root.childNodes[i], Func, args );
  2485.         }
  2486.     }
  2487.     
  2488.     if ( type == "post" )
  2489.     {
  2490.         Func( root, args );
  2491.     }
  2492. }
  2493.  
  2494. //
  2495. //    End DOM traversal functions
  2496. //
  2497.  
  2498. //
  2499. //    Button effects
  2500. //
  2501.  
  2502. var gButton        = null;
  2503. var gTabIndex    = 1;
  2504.  
  2505. function MakeButton( td, title, outImagePath, overImagePath, selectedImagePath, width, height, text )
  2506. {
  2507.     var div    = document.createElement( "div" );
  2508.     
  2509.     div.tabIndex = gTabIndex++;
  2510.     
  2511.     title ? div.title = title : false;
  2512.     div.setAttribute( "MadCap:outImage", outImagePath );
  2513.     div.setAttribute( "MadCap:overImage", overImagePath );
  2514.     div.setAttribute( "MadCap:selectedImage", selectedImagePath );
  2515.     div.setAttribute( "MadCap:width", width );
  2516.     div.setAttribute( "MadCap:height", height );
  2517.     
  2518.     FMCPreloadImage( outImagePath );
  2519.     FMCPreloadImage( overImagePath );
  2520.     FMCPreloadImage( selectedImagePath );
  2521.     
  2522.     div.appendChild( document.createTextNode( text ) );
  2523.     td.appendChild( div );
  2524.     
  2525.     InitButton( div );
  2526. }
  2527.  
  2528. function InitButton( button )
  2529. {
  2530.     var width    = parseInt( FMCGetMCAttribute( button, "MadCap:width" ) ) + "px";
  2531.     var height    = parseInt( FMCGetMCAttribute( button, "MadCap:height" ) ) + "px";
  2532.     var image    = FMCGetMCAttribute( button, "MadCap:outImage" );
  2533.     
  2534.     if ( image != null )
  2535.     {
  2536.         if ( !image.StartsWith( "url", false ) || !image.EndsWith( ")", false ) )
  2537.         {
  2538.             image = FMCCreateCssUrl( image );
  2539.         }
  2540.  
  2541.         button.style.backgroundImage = image;
  2542.     }
  2543.     
  2544.     button.style.cursor = "default";
  2545.     button.style.width = width;
  2546.     button.style.height = height;
  2547.     button.onmouseover = ButtonOnOver;
  2548.     button.onmouseout = ButtonOnOut;
  2549.     button.onmousedown = ButtonOnDown;
  2550.  
  2551.     button.parentNode.style.width = width;
  2552.     button.parentNode.style.height = height;
  2553. }
  2554.  
  2555. function ButtonOnOver()
  2556. {
  2557.     var image    = FMCGetMCAttribute( this, "MadCap:overImage" );
  2558.     
  2559.     if ( !image.StartsWith( "url", false ) || !image.EndsWith( ")", false ) )
  2560.     {
  2561.         image = FMCCreateCssUrl( image );
  2562.     }
  2563.     
  2564.     this.style.backgroundImage = image;
  2565. }
  2566.  
  2567. function ButtonOnOut()
  2568. {
  2569.     var image    = FMCGetMCAttribute( this, "MadCap:outImage" );
  2570.     
  2571.     if ( !image.StartsWith( "url", false ) || !image.EndsWith( ")", false ) )
  2572.     {
  2573.         image = FMCCreateCssUrl( image );
  2574.     }
  2575.     
  2576.     this.style.backgroundImage = image;
  2577. }
  2578.  
  2579. function ButtonOnDown()
  2580. {
  2581.     StartPress( this ); return false;
  2582. }
  2583.  
  2584. function StartPress( node )
  2585. {
  2586.     // Debug
  2587.     //window.status += "s";
  2588.     
  2589.     gButton = node;
  2590.     
  2591.     if ( document.body.setCapture )
  2592.     {
  2593.         document.body.setCapture();
  2594.         
  2595.         document.body.onmousemove = Press;
  2596.         document.body.onmouseup = EndPress;
  2597.     }
  2598.     else if ( document.addEventListener )
  2599.     {
  2600.         document.addEventListener( "mousemove", Press, true );
  2601.         document.addEventListener( "mouseup", EndPress, true );
  2602.     }
  2603.     
  2604.     gButton.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( gButton, "MadCap:selectedImage" ) );
  2605.     gButton.onmouseover = function() { this.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( this, "MadCap:selectedImage" ) ); };
  2606. }
  2607.  
  2608. function Press( e )
  2609. {
  2610.     // Debug
  2611.     //window.status += "p";
  2612.     
  2613.     if ( !e )
  2614.     {
  2615.         e = window.event;
  2616.         target = e.srcElement;
  2617.     }
  2618.     else if ( e.target )
  2619.     {
  2620.         target = e.target;
  2621.     }
  2622.     
  2623.     if ( target == gButton )
  2624.     {
  2625.         gButton.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( gButton, "MadCap:selectedImage" ) );
  2626.     }
  2627.     else
  2628.     {
  2629.         gButton.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( gButton, "MadCap:outImage" ) );
  2630.     }
  2631. }
  2632.  
  2633. function EndPress( e )
  2634. {
  2635.     // Debug
  2636.     //window.status += "e";
  2637.     
  2638.     var target  = null;
  2639.     
  2640.     if ( !e )
  2641.     {
  2642.         e = window.event;
  2643.         target = e.srcElement;
  2644.     }
  2645.     else if ( e.target )
  2646.     {
  2647.         target = e.target;
  2648.     }
  2649.     
  2650.     if ( target == gButton )
  2651.     {
  2652.         // Debug
  2653.         //window.status += "c";
  2654.         
  2655.         gButton.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( gButton, "MadCap:overImage" ) );
  2656.     }
  2657.     
  2658.     gButton.onmouseover = function() { this.style.backgroundImage = FMCCreateCssUrl( FMCGetMCAttribute( this, "MadCap:overImage" ) ); };
  2659.     
  2660.     if ( document.body.releaseCapture )
  2661.     {
  2662.         document.body.releaseCapture();
  2663.         
  2664.         document.body.onmousemove = null;
  2665.         document.body.onmouseup = null;
  2666.     }
  2667.     else if ( document.removeEventListener )
  2668.     {
  2669.         document.removeEventListener( "mousemove", Press, true );
  2670.         document.removeEventListener( "mouseup", EndPress, true );
  2671.     }
  2672.     
  2673.     gButton = null;
  2674. }
  2675.  
  2676. //
  2677. //    End button effects
  2678. //
  2679.  
  2680. //
  2681. //    String helpers
  2682. //
  2683.  
  2684. String.prototype.IsNullOrEmpty = function()
  2685. {
  2686.     if ( this == null )
  2687.     {
  2688.         return true;
  2689.     }
  2690.     
  2691.     if ( this.length == 0 )
  2692.     {
  2693.         return true;
  2694.     }
  2695.     
  2696.     return false;
  2697. }
  2698.  
  2699. String.prototype.StartsWith = function( str, caseSensitive )
  2700. {
  2701.     if ( str == null )
  2702.     {
  2703.         return false;
  2704.     }
  2705.     
  2706.     if ( this.length < str.length )
  2707.     {
  2708.         return false;
  2709.     }
  2710.     
  2711.     var value1    = this;
  2712.     var value2    = str;
  2713.     
  2714.     if ( !caseSensitive )
  2715.     {
  2716.         value1 = value1.toLowerCase();
  2717.         value2 = value2.toLowerCase();
  2718.     }
  2719.     
  2720.     if ( value1.substring( 0, value2.length ) == value2 )
  2721.     {
  2722.         return true;
  2723.     }
  2724.     else
  2725.     {
  2726.         return false;
  2727.     }
  2728. }
  2729.  
  2730. String.prototype.EndsWith = function( str, caseSensitive )
  2731. {
  2732.     if ( str == null )
  2733.     {
  2734.         return false;
  2735.     }
  2736.     
  2737.     if ( this.length < str.length )
  2738.     {
  2739.         return false;
  2740.     }
  2741.     
  2742.     var value1    = this;
  2743.     var value2    = str;
  2744.     
  2745.     if ( !caseSensitive )
  2746.     {
  2747.         value1 = value1.toLowerCase();
  2748.         value2 = value2.toLowerCase();
  2749.     }
  2750.     
  2751.     if ( value1.substring( value1.length - value2.length ) == value2 )
  2752.     {
  2753.         return true;
  2754.     }
  2755.     else
  2756.     {
  2757.         return false;
  2758.     }
  2759. }
  2760.  
  2761. String.prototype.Contains = function( str, caseSensitive )
  2762. {
  2763.     var value1    = this;
  2764.     var value2    = str;
  2765.     
  2766.     if ( !caseSensitive )
  2767.     {
  2768.         value1 = value1.toLowerCase();
  2769.         value2 = value2.toLowerCase();
  2770.     }
  2771.     
  2772.     return value1.indexOf( value2 ) != -1;
  2773. }
  2774.  
  2775. String.prototype.Equals = function( str, caseSensitive )
  2776. {
  2777.     var value1    = this;
  2778.     var value2    = str;
  2779.     
  2780.     if ( !caseSensitive )
  2781.     {
  2782.         value1 = value1.toLowerCase();
  2783.         value2 = value2.toLowerCase();
  2784.     }
  2785.     
  2786.     return value1 == value2;
  2787. }
  2788.  
  2789. String.prototype.CountOf = function( str, caseSensitive )
  2790. {
  2791.     var count    = 0;
  2792.     var value1    = this;
  2793.     var value2    = str;
  2794.     
  2795.     if ( !caseSensitive )
  2796.     {
  2797.         value1 = value1.toLowerCase();
  2798.         value2 = value2.toLowerCase();
  2799.     }
  2800.     
  2801.     var lastIndex    = -1;
  2802.     
  2803.     while ( true )
  2804.     {
  2805.         lastIndex = this.indexOf( str, lastIndex + 1 );
  2806.         
  2807.         if ( lastIndex == -1 )
  2808.         {
  2809.             break;
  2810.         }
  2811.         
  2812.         count++;
  2813.     }
  2814.     
  2815.     return count;
  2816. }
  2817.  
  2818. //
  2819. //    End String helpers
  2820. //
  2821.